/**
 * 2013 2013-5-7
 */
package com.surfilter.dp;

import java.awt.EventQueue;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.UIManager;

import com.surfilter.dp.context.ContextHolder;
import com.surfilter.dp.util.PropertyFileManager;
import com.surfilter.dp.view.ConfigDialog;
import com.surfilter.dp.view.MainWindow;

/**
 *
 */
public class Activitor {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if(!PropertyFileManager.validateProps()){
			final ConfigDialog dialog = new ConfigDialog(null);
			dialog.setVisible(true);
			dialog.addWindowListener(new WindowAdapter() {
				@Override
				public void windowClosed(WindowEvent e) {
					super.windowClosed(e);
					initMainWindow();
					dialog.removeWindowListener(this);
				}
				
			});
		}else{
			initMainWindow();
		}
	}
	
	private static void initMainWindow(){
		ContextHolder.getInstance().init();
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
					MainWindow frame = new MainWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	

}
